home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_01 / allison / copy1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-02  |  272 b   |  16 lines

  1. LISTING 4 - A Function that copies a file via character I/O
  2.  
  3. /* copy1.c */
  4. #include <stdio.h>
  5.  
  6. int copy(FILE *dest, FILE *source)
  7. {
  8.     int c;
  9.  
  10.     while ((c = getc(source)) != EOF)
  11.         if (putc(c,dest) == EOF)
  12.             return EOF;
  13.     return 0;
  14. }
  15.  
  16.